﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Common.Logging;
using Common.Logging.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Quartz.WebManager.SimpleLog
{
    /// <summary>
    /// Tests the <see cref="FileLoggerFactoryAdapter"/> class.
    /// </summary>
    [TestClass]
    public class FileLoggerFactoryAdapterTest
    {
        /// <summary>
        /// Tests the constructor of the <see cref="FileLoggerFactoryAdapter"/> class.
        /// </summary>
        [TestMethod]
        public void Constructor_Default()
        {
            var instance = new FileLoggerFactoryAdapter();
            Assert.AreEqual("output.log", instance.FileName);
        }

        /// <summary>
        /// Tests the constructor of the <see cref="FileLoggerFactoryAdapter"/> class.
        /// </summary>
        [TestMethod]
        public void Constructor_Properties()
        {
            NameValueCollection properties = new NameValueCollection();
            properties.Add("fileName", "test.log");
            properties.Add("level", "Fatal");
            var instance = new FileLoggerFactoryAdapter(properties);
            Assert.AreEqual("test.log", instance.FileName);
            Assert.AreEqual(LogLevel.Fatal, instance.Level);
        }

        /// <summary>
        /// Tests the constructor of the <see cref="FileLoggerFactoryAdapter"/> class.
        /// </summary>
        [TestMethod]
        public void Constructor_Complete()
        {
            var instance = new FileLoggerFactoryAdapter(LogLevel.Fatal, false, false, false, null, "test.log");
            Assert.AreEqual("test.log", instance.FileName);
            Assert.AreEqual(LogLevel.Fatal, instance.Level);
        }
    }
}
